﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

public partial class admin_managerDetail : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {

    }
    protected void ObDetail_Updating(object sender, ObjectDataSourceMethodEventArgs e)
    {
        if (!Page.IsValid)
        {
            e.Cancel = true;
        }
        MODEL.LostAndFound updateLAF = (MODEL.LostAndFound)e.InputParameters[0];
        updateLAF.LId = Convert.ToInt32(((Label)DetailsView1.FindControl("labLID")).Text);
        updateLAF.UserId = Convert.ToInt32(((HiddenField)DetailsView1.FindControl("hiddenUId")).Value);
        #region  图片
        FileUpload fimg=(FileUpload)DetailsView1.FindControl("FUImg");
        if (fimg.HasFile)
        {
            //判断图片大小，不能超过500kb
            if (fimg.PostedFile.ContentLength < 500 * 1024)
            {
                //判断文件的后缀名，是否为图片
                if (System.IO.Path.GetExtension(fimg.FileName) == ".jpg" || System.IO.Path.GetExtension(fimg.FileName) == ".gif" || System.IO.Path.GetExtension(fimg.FileName) == ".png" || System.IO.Path.GetExtension(fimg.FileName) == ".jpeg")
                {
                    //model.Image = FUImg.FileName;
                    //string savePath = Server.MapPath("imgpublish/" + FUImg.FileName);//考虑到图片冲突的问题  所以不能用这方法
                    string s = Guid.NewGuid().ToString();
                    updateLAF.Image = s + System.IO.Path.GetExtension(fimg.FileName);
                    string savePath = Server.MapPath("../imgpublish/" + s + System.IO.Path.GetExtension(fimg.FileName));
                    fimg.SaveAs(savePath);
                }
                else
                {
                    //updateLAF.Image = "";
                }
            }
            else
            {
                //updateLAF.Image = "";
            }
        }
        else
        {
            //updateLAF.Image = "";
        }
        #endregion
        updateLAF.IsDel = false;
    }

   
}